<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CSS 固定定位(fixed)</title>
    <!--相对body定位-->
    <style>
      div {
        border: 1px solid black;
      }
      .parent {
        width: 400px;
        height: 400px;
        margin: 50px auto;
        padding: 10px;
        /*定位点*/
        position: relative;
      }
      .fixed {
        position: fixed;
      }
      #div1 {
        background-color: red;
      }
      #div2 {
        background-color: green;
        left: 0px;
        bottom: 0px;
      }
      #div3 {
        width: 200px;
        height: 200px;
        background-color: blue;
        top: 100px;
        left: 100px;
        z-index: 999;
      }
      #div4 {
        background-color: orange;
        left: 0px;
        right: 0px;
        bottom: 50px;
      }
      #div5 {
        background-color: purple;
        top: 0px;
        bottom: 0px;
        right: 50px;
      }
    </style>
  </head>
  <body>
    <div class="parent">
      <!--然后再渲染 脱离 文档流的元素-->
      <div id="div1" class="fixed">绝对定位</div>
      <div id="div2" class="fixed">默认尺寸绝对定位</div>
      <div id="div3" class="fixed">设置尺寸绝对定位</div>
      <div id="div4" class="fixed">水平拉伸绝对定位</div>
      <div id="div5" class="fixed">垂直拉伸绝对定位</div>
      <!--游览器先渲染 遵循 文档流的元素-->
      <div>静态定位</div>
    </div>
  </body>
</html>
